/**
 * 给定若干条记录，按人合并并且处理即可
 * 因为字符串较短，判后缀暴力即可。
 */
#include <bits/stdc++.h>
using namespace std;
#include <bits/extc++.h>
using namespace __gnu_pbds;

using llt = long long;
using vi = vector<int>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using vll = vector<llt>;

int N;
map<string, vector<string>> Map;

void proc(vector<string> & vec){
    vector<string> tmp;
    for(auto s : vec){
        reverse(s.begin(), s.end());
        tmp.emplace_back(s);
    }
    sort(tmp.begin(), tmp.end());

    vec.clear();
    for(int i=1;i<tmp.size();++i){
        if(tmp[i].find(tmp[i - 1]) != 0){
            vec.emplace_back(tmp[i - 1]);
            reverse(vec.back().begin(), vec.back().end());
        }
    }

    vec.emplace_back(tmp.back());
    reverse(vec.back().begin(), vec.back().end());
    sort(vec.begin(), vec.end());
    return;
}

void work(){ 
    cin >> N;
    for(int i=0;i<N;++i){
        string s; cin >> s;
        auto it = Map.find(s);
        if(it == Map.end()){
            it = Map.insert(it, {s, vector<string>{}});
        }
        int k; cin >> k;
        for(int j=0;j<k;++j){
            string a;
            cin >> a;
            it->second.emplace_back(a);
        }
    }

    for(auto & p : Map){
        proc(p.second);
    }

    cout << Map.size() << endl;
    for(const auto & p : Map){
        cout << p.first << " " << p.second.size();
        for(auto i : p.second){
            cout << " " << i;
        }
        cout << endl;
    }
	return;
}

int main(){
#ifndef ONLINE_JUDGE
    freopen("z.txt", "r", stdin);
#endif
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);	
    int nofkase = 1;
	// cin >> nofkase;
	while(nofkase--) work();
	return 0;
}